home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / IShield for Visual C++ 6.0 / DATA1.CAB / Include_Files / WINSUB.RUL < prev   
Encoding:
Text File  |  1997-11-20  |  26.0 KB  |  793 lines

  1.  
  2.  /*===========================================================================*/
  3.  /*                                                                           */
  4.  /*           (c) InstallShield Software Corporation (1996-1997)              */
  5.  /*            (c)  InstallShield Corporation  (1990-1996)                    */
  6.  /*                       Schaumburg, Illinois 60173                          */
  7.  /*                          All Rights Reserved                              */
  8.  /*                           InstallShield (R)                               */
  9.  /*                                                                           */
  10.  /*  FILE:   WINSUB.RUL                                                       */
  11.  /*                                                                           */
  12.  /*  PURPOSE:                                                                 */
  13.  /*      This script interfaces to several Windows APIs.                      */
  14.  /*      For example, WinSubIsWindow (hWnd) interfaces to Windows             */
  15.  /*          IsWindow API. Please refer to IsWindow API in Windows            */
  16.  /*          Programmer's Manual for the detailed description.                */
  17.  /*                                                                           */
  18.  /*   RESOURCE: NONE                                                          */
  19.  /*                                                                           */
  20.  /*   RELATED FILES: WINSUB.H                                                 */
  21.  /*                                                                           */
  22.  /*   MAIN FUNCTION CALLS:                                                    */
  23.  /*     _WinSubGetModuleHandle ( szModule );                                  */
  24.  /*       Retrieves the handle of the specified module.                       */
  25.  /*                                                                           */
  26.  /*     _WinSubShowCursor     ( nShow );                                      */         
  27.  /*       This function shows or hides the cursor.                            */
  28.  /*                                                                           */
  29.  /*    _WinSubShowWindow     ( hWnd, nShow );                                 */
  30.  /*       This function sets the given window's visibility state.             */
  31.  /*                                                                           */
  32.  /*    _WinSubFocusControl   ( hWnd, nBtnId );                                */
  33.  /*       This function sets the input focus to the given child window.       */
  34.  /*       all subsequent keyboard input is directed to this child window.     */
  35.  /*       The child window, if any, that previously had the input focus       */
  36.  /*       loses it.                                                           */
  37.  /*                                                                           */
  38.  /*    _WinSubFocusWindow    ( hWnd );                                        */
  39.  /*       This function sets the input focus to the given  window.            */
  40.  /*       all subsequent keyboard input is directed to this window.  The      */
  41.  /*       window, if any, that previously had the input focus loses it.       */
  42.  /*                                                                           */
  43.  /*    _WinSubEnableControl  ( hWnd, nBtnID, nEnable );                       */
  44.  /*       This function enables or disables mouse and keyboard input to       */
  45.  /*       the given window or control.  When input is disabled, the window    */
  46.  /*       ignores input such as mouse clicks and key presses.  When input     */
  47.  /*       is enabled, the window processes all input.                         */
  48.  /*                                                                           */
  49.  /*    _WinSubGetChildWindow ( hWnd, nBtnID );                                */
  50.  /*       This function retrieves the handle of a control that is in the      */
  51.  /*       given dialog box                                                    */
  52.  /*                                                                           */
  53.  /*    _WinSubEnableWindow   ( HWND, INT );                                   */
  54.  /*       This function enables or disables mouse and keyboard input to       */
  55.  /*       the given window or control.  When input is disabled, the window    */
  56.  /*       ignores input such as mouse clicks and key presses.  When input     */
  57.  /*       is enabled, the window processes all input.                         */
  58.  /*                                                                           */
  59.  /*    _WinSubSetWindowTitle ( hWnd, szText );                                */
  60.  /*       This function sets the given window's title to the specified text.  */
  61.  /*                                                                           */
  62.  /*    _WinSubCenterWindow   ( hWnd );                                        */
  63.  /*       This function changes the position and dimensions to be the center  */
  64.  /*       of the screen.                                                      */
  65.  /*                                                                           */
  66.  /*    _WinSubIsWindow       ( hWnd );                                        */
  67.  /*       This function determines whether the given window handle is valid.  */
  68.  /*                                                                           */
  69.  /*    _WinSubGetWindowRect  ( hWnd, nOX, nOY, nSX, nSY );                    */
  70.  /*       This function retrieves the dimensions of the bounding rectangle    */
  71.  /*       of a given window.                                                  */
  72.  /*                                                                           */
  73.  /*    _WinSubGetClientRect ( hWnd, nOX, nOY, nSX, nSY )                      */
  74.  /*       This function retrieves the client coordinates of a window's client */
  75.  /*       area.                                                               */
  76.  /*                                                                           */
  77.  /*    _WinSubSetWindowPos ( hWnd, nNX, nNY, nSX, nSY, sFlags )               */
  78.  /*       This function changes the size, position, and Z-order of child,     */
  79.  /*       pop-up, and top-level windows.                                      */
  80.  /*                                                                           */
  81.  /*    _WinSubMoveWindow ( hWnd, nNX, nNY, nSX, nSY, sFlags )                 */
  82.  /*       This function changes the position and dimensions of a window.      */
  83.  /*                                                                           */
  84.  /*    _WinSubPostMessage ( hWnd, nCmd, sParam1, lParam2 )                    */
  85.  /*       This function posts a message in a window's message queue and       */
  86.  /*       then returns without waiting for the corresponding window to        */
  87.  /*       process the message.                                                */
  88.  /*                                                                           */
  89.  /*                                                                           */
  90.  /*===========================================================================*/
  91.  
  92. //-----------------------------------------------------------------------------
  93. // PARAMETERS
  94. //      szModules specifies module name to be tested.
  95. //
  96. // DESCRIPTION
  97. //      The routine returns 0 if module is not found, otherwise return -1.
  98. //
  99. // PURPOSE
  100. //      Retrieves the handle of the specified module.
  101. //-----------------------------------------------------------------------------
  102.  
  103. function _WinSubGetModuleHandle ( szModule )
  104. HWND  hInst;
  105. STRING svResult;
  106. NUMBER nvResult;
  107. begin
  108.      // Retrieve module handle
  109.      hInst = GetModuleHandle (szModule);
  110.  
  111.     if( hInst < 0 ) then
  112.         _WinSubErrDLLFunc ( "GetModuleHandle" );
  113.         return -1;
  114.     endif;
  115.  
  116.  
  117.     // Determine Operating System type, and accordingly, return the
  118.     // result
  119.  
  120.     if( !GetSystemInfo( OS, nvResult, svResult ) ) then
  121.         if( ( nvResult = IS_WINDOWS95 ) || ( nvResult = IS_WINDOWSNT ) ) then
  122.             if( hInst > 0 ) then
  123.                 return 1;
  124.             else
  125.                 return 0;
  126.             endif;
  127.         else
  128.             hInst = hInst & 0x0000FFFF;
  129.             if( hInst > 0) then
  130.                 return 1;
  131.             else
  132.                 return 0;
  133.             endif;
  134.         endif;
  135.     endif;
  136.  
  137.     return -1;
  138.  
  139. end;
  140.  
  141. //-----------------------------------------------------------------------------
  142. // PARAMETER:
  143. //      nShow specifies whether the display count to be increased
  144. //            or decreased. The display count is increased if nShow is
  145. //            nonzero. Otherwise, it is decreased. The cusor is displayed
  146. //            only if the display count is greater than or equal to zero.
  147. // PURPOSE
  148. //      This function shows or hides the cursor.
  149. //
  150. //-----------------------------------------------------------------------------
  151. function _WinSubShowCursor ( nShow )
  152. NUMBER  nRet;
  153.  
  154. begin
  155.         // Check if the given window handle is valid?
  156.         nRet = ShowCursor ( nShow );
  157.  
  158.        if( nRet = -1 ) then
  159.        else
  160.            // Need to mark out the higher 2 bytes
  161.            nRet = nRet & 0x0000FFFF;
  162.            if( nRet != 0 ) then
  163.                nRet = 1;
  164.            endif;
  165.        endif;
  166.  
  167.         return nRet;
  168. end;
  169.  
  170. //-----------------------------------------------------------------------------
  171. // PARAMETERS:
  172. //      hWnd  specifies the window
  173. //      nShow specifies how the window is to be shown which
  174. //            supports all SWP_* flags under Windows.
  175. // PURPOSE
  176. //     This function sets the given window's visibility state.
  177. //
  178. //-----------------------------------------------------------------------------
  179. function _WinSubShowWindow ( hWnd, nShow )
  180.  
  181. NUMBER  nRet;
  182.  
  183. begin
  184.         // Check if the given window handle is valid?
  185.         nRet = ShowWindow ( hWnd, nShow );
  186.         if ( nRet = -1 ) then
  187.  
  188.            _WinSubErrDLLFunc ( "ShowWindow" );
  189.            nRet = -1;
  190.  
  191.         else
  192.  
  193.            // Need to mark out the higher 2 bytes
  194.            nRet = nRet & 0x0000FFFF;
  195.            if ( nRet != 0 ) then
  196.               nRet = 1;
  197.            endif;
  198.  
  199.         endif;
  200.  
  201.         return nRet;
  202. end;
  203.  
  204. //-----------------------------------------------------------------------------
  205. // PARAMETERS:
  206. //      hWnd   specifies the window or the dialogbox.
  207. //      nBtnId specifies the identifier of the control.
  208. // PURPOSE
  209. //             This function sets the input focus to the given child window.
  210. //             all subsequent keyboard input is directed to this child window.
  211. //             The child window, if any, that previously had the input focus
  212. //             loses it.
  213. //
  214. //-----------------------------------------------------------------------------
  215. function _WinSubFocusControl ( hWnd, nBtnID )
  216.  
  217. INT     hCtrl;
  218. INT     nRet;
  219.  
  220. begin
  221.  
  222.         // Check window handle
  223.         if ( _WinSubIsWindow ( hWnd ) <= 0 ) then
  224.            return -1;
  225.         endif;
  226.  
  227.         // Retrieve child window handle
  228.         hCtrl = _WinSubGetChildWindow ( hWnd, nBtnID );
  229.         if ( hCtrl <= 0 ) then
  230.            return -1;
  231.         endif;
  232.  
  233.         // Enable/disable the window
  234.         nRet = _WinSubFocusWindow ( hCtrl );
  235.  
  236.         return nRet;
  237. end;
  238.  
  239. //-----------------------------------------------------------------------------
  240. // PARAMETER:
  241. //      hWnd specifies the window
  242. // PURPOSE
  243. //             This function sets the input focus to the given  window.
  244. //             all subsequent keyboard input is directed to this window.  The
  245. //             window, if any, that previously had the input focus loses it.
  246. //
  247. //-----------------------------------------------------------------------------
  248. function _WinSubFocusWindow ( hWnd )
  249.  
  250. INT     nRet;
  251.  
  252. begin
  253.  
  254.         // Check window handle
  255.         if ( _WinSubIsWindow ( hWnd ) <= 0 ) then
  256.            return -1;
  257.         endif;
  258.  
  259.         // Check if the given window handle is valid?
  260.         nRet = SetFocus ( hWnd );
  261.         if ( nRet = -1 ) then
  262.  
  263.            _WinSubErrDLLFunc ( "SetFocus" );
  264.            nRet = -1;
  265.  
  266.         else
  267.  
  268.            // Need to mark out the higher 2 bytes
  269.            nRet = nRet & 0x0000FFFF;
  270.            if ( nRet != 0 ) then
  271.               nRet = 1;
  272.            endif;
  273.  
  274.         endif;
  275.  
  276.         return nRet;
  277. end;
  278.  
  279.  
  280. //-----------------------------------------------------------------------------
  281. // PARAMETERS:
  282. //      hWnd    specifies the window or the dialogbox.
  283. //      nBtnID  specifies the identifier of the control.
  284. //      nEnable specifies to enable or to disable the control.
  285. // PURPOSE
  286. //             This function enables or disables mouse and keyboard input to
  287. //             the given window or control.  When input is disabled, the window
  288. //             ignores input such as mouse clicks and key presses.  When input
  289. //             is enabled, the window processes all input.
  290. //
  291. //-----------------------------------------------------------------------------
  292. function _WinSubEnableControl ( hWnd, nBtnID, nEnable )
  293.  
  294. INT     hCtrl;
  295. INT     nRet;
  296.  
  297. begin
  298.  
  299.         // Check window handle
  300.         if ( _WinSubIsWindow ( hWnd ) <= 0 ) then
  301.            return -1;
  302.         endif;
  303.  
  304.         // Retrieve child window handle
  305.         hCtrl = _WinSubGetChildWindow ( hWnd, nBtnID );
  306.         if ( hCtrl <= 0 ) then
  307.            return -1;
  308.         endif;
  309.  
  310.         // Enable/disable the window
  311.         nRet = _WinSubEnableWindow ( hCtrl, nEnable );
  312.  
  313.         return nRet;
  314. end;
  315.  
  316.  
  317. //-----------------------------------------------------------------------------
  318. // PARAMETERS:
  319. //      hWnd   specifies the window or the dialogbox.
  320. //      nBtnID specifies the identifier of the child window.
  321. // PURPOSE
  322. //             This function retrieves the handle of a control that is in the
  323. //             given dialog box.
  324. //
  325. //-----------------------------------------------------------------------------
  326. function _WinSubGetChildWindow ( hWnd, nBtnID )
  327.  
  328. INT     hCtrl;
  329.  
  330. begin
  331.  
  332.         // Check window handle
  333.         if ( _WinSubIsWindow ( hWnd ) <= 0 ) then
  334.            return -1;
  335.         endif;
  336.  
  337.         // Check if the given window handle is valid?
  338.         hCtrl = GetDlgItem ( hWnd, nBtnID );
  339.         if ( hCtrl = -1 ) then
  340.  
  341.            _WinSubErrDLLFunc ( "GetDlgItem" );
  342.            hCtrl = -1;
  343.  
  344.         else
  345.  
  346.            // Need to mark out the higher 2 bytes
  347.            hCtrl = hCtrl & 0x0000FFFF;
  348.  
  349.         endif;
  350.  
  351.         return hCtrl;
  352.  
  353. end;
  354.  
  355.  
  356. //-----------------------------------------------------------------------------
  357. // PARAMETERS:
  358. //      hWnd   specifies the window.
  359. //      nBtnID specifies to enable or to disable the window.
  360. // PURPOSE
  361. //             This function enables or disables mouse and keyboard input to
  362. //             the given window or control.  When input is disabled, the window
  363. //             ignores input such as mouse clicks and key presses.  When input
  364. //             is enabled, the window processes all input.
  365. //
  366. //-----------------------------------------------------------------------------
  367. function _WinSubEnableWindow ( hWnd, nEnable )
  368.  
  369. SHORT   sFlag;
  370. INT     nRet;
  371.  
  372. begin
  373.  
  374.         // Check window handle
  375.         if ( _WinSubIsWindow ( hWnd ) <= 0 ) then
  376.            return -1;
  377.         endif;
  378.  
  379.         // Setup flag
  380.         if ( nEnable = 0 ) then
  381.            sFlag = 0;
  382.         else
  383.            sFlag = 1;
  384.         endif;
  385.  
  386.  
  387.         // Check if the given window handle is valid?
  388.         nRet = EnableWindow ( hWnd, sFlag );
  389.         if ( nRet = -1 ) then
  390.  
  391.            _WinSubErrDLLFunc ( "Enable" );
  392.            nRet = -1;
  393.  
  394.         else
  395.  
  396.            // Need to mark out the higher 2 bytes
  397.            nRet = nRet & 0x0000FFFF;
  398.            if ( nRet != 0 ) then
  399.               nRet = 1;
  400.            endif;
  401.  
  402.         endif;
  403.  
  404.         return nRet;
  405.  
  406. end;
  407.  
  408.  
  409. //-----------------------------------------------------------------------------
  410. // PARAMETERS:
  411. //      hWnd   specifies the window.
  412. //      szText specifies the new caption text.
  413. // PURPOSE
  414. //      This function sets the given window's title to the specified text.
  415. //
  416. //-----------------------------------------------------------------------------
  417. function _WinSubSetWindowTitle ( hWnd, szText )
  418.  
  419. INT             nRet;
  420.  
  421. begin
  422.  
  423.         // Check window handle
  424.         if ( _WinSubIsWindow ( hWnd ) <= 0 ) then
  425.            return -1;
  426.         endif;
  427.  
  428.  
  429.         // Set window title
  430.         nRet = _WinSubSetWindowText ( hWnd, szText );
  431.  
  432.         return nRet;
  433. end;
  434.  
  435.  
  436. //-----------------------------------------------------------------------------
  437. // PARAMETER:
  438. //      hWnd is the window or the dialogbox to be centered.
  439. // PURPOSE
  440. //      This function changes the position and dimensions to be the center
  441. //      of the screen.
  442. //
  443. //-----------------------------------------------------------------------------
  444. function _WinSubCenterWindow ( hWnd )
  445.  
  446. INT             nRet;
  447. INT             nOX, nOY, nSX, nSY;
  448. INT             nNX, nNY;
  449. SHORT           sFlags;
  450.  
  451. begin
  452.  
  453. // ## remove this line when hide/show dialogbox are supported
  454.         // return 0;
  455.  
  456.         // Check window handle
  457.         if ( _WinSubIsWindow ( hWnd ) <= 0 ) then
  458.            return -1;
  459.         endif;
  460.  
  461.         // Retrieve window rect
  462.         _WinSubGetWindowRect ( hWnd, nOX, nOY, nSX, nSY );
  463.  
  464.         // Retrieve screen extent
  465.         GetExtents ( nNX, nNY );
  466.  
  467.         // Calculate new orig
  468.         nSX = nSX - nOX + 1;
  469.         nSY = nSY - nOY + 1;
  470.         nNX = ( nNX - nSX ) / 2;
  471.         nNY = ( nNY - nSY ) / 2;
  472.  
  473.         // Move the window
  474.         sFlags = 1;
  475.         nRet   = _WinSubMoveWindow ( hWnd, nNX, nNY, nSX, nSY, sFlags );
  476.  
  477.         return nRet;
  478. end;
  479.  
  480.  
  481. //-----------------------------------------------------------------------------
  482. // PARAMETERS:
  483. //      hWnd   specifies the window.
  484. //      szText specifies the new caption text.
  485. // PURPOSE
  486. //
  487. //-----------------------------------------------------------------------------
  488. function _WinSubSetWindowText ( hWnd, szText )
  489.  
  490. INT     nRet;
  491. begin
  492.  
  493.         // Check window handle
  494.         if ( _WinSubIsWindow ( hWnd ) <= 0 ) then
  495.            return -1;
  496.         endif;
  497.  
  498.         // Check if the given window handle is valid?
  499.         nRet = SetWindowText ( hWnd, szText );
  500.         if ( nRet = -1 ) then
  501.  
  502.            _WinSubErrDLLFunc ( "SetWindowText" );
  503.            nRet = -1;
  504.  
  505.         else
  506.  
  507.            nRet = 0 ;
  508.  
  509.         endif;
  510.  
  511.         return nRet;
  512.  
  513. end;
  514.  
  515.  
  516. //-----------------------------------------------------------------------------
  517. // PARAMETER:
  518. //      hWnd is the window or the dialogbox to be centered.
  519. // PURPOSE
  520. //        This function determines whether the given window handle is valid.
  521. //
  522. //-----------------------------------------------------------------------------
  523. function _WinSubIsWindow ( hWnd )
  524.  
  525. INT     nRet;
  526.  
  527. begin
  528.  
  529.         // Check if the given window handle is valid?
  530.         nRet = IsWindow ( hWnd );
  531.         if ( nRet = -1 ) then
  532.  
  533.            _WinSubErrDLLFunc ( "IsWindow" );
  534.            nRet = -1;
  535.  
  536.         else
  537.  
  538.            // Need to mark out the higher 2 bytes
  539.            nRet = nRet & 0x0000FFFF;
  540.            if ( nRet != 0 ) then
  541.               nRet = 1;
  542.            endif;
  543.  
  544.         endif;
  545.  
  546.         return nRet;
  547. end;
  548.  
  549.  
  550. //-----------------------------------------------------------------------------
  551. // PARAMETERS:
  552. //      (INPUT)
  553. //      hWnd specifies the window.
  554. //      (OUTPUT)
  555. //      nOX receives the X-coord. of the upper-left corner.
  556. //      nOY receives the Y-coord. of the upper-left corner.
  557. //      nSX receives the X-coord. of the lower-right corner.
  558. //      nSY receives the Y-coord. of the lower-right corner.
  559. // PURPOSE
  560. //       This function retrieves the dimensions of the bounding rectangle
  561. //       of a given window.
  562. //
  563. //-----------------------------------------------------------------------------
  564. function _WinSubGetWindowRect ( hWnd, nOX, nOY, nSX, nSY )
  565.  
  566. NUMBER          nRet;
  567. POINTER         pRect;
  568. WINRECTSTRUCT   rect;
  569. STRING          szTemp [MAX_WINSUB_TMPSTRING_LENGTH];
  570.  
  571. begin
  572.  
  573.         // Check window handle
  574.         if ( _WinSubIsWindow ( hWnd ) <= 0 ) then
  575.            return -1;
  576.         endif;
  577.  
  578.         // Retrieve the address of the structure
  579.         pRect = AddressStruct ( rect );
  580.  
  581.         // Retrieve window rect
  582.         nRet = GetWindowRect ( hWnd, pRect );
  583.         if ( nRet = -1 ) then
  584.  
  585.            // Can not locate the function?
  586.            _WinSubErrDLLFunc ( "GetWindowRect" );
  587.            nRet = -1;
  588.  
  589.         else
  590.  
  591.            // Separate each field of the rect structure
  592.            StructGet ( rect, "WINRECTSTRUCT", "origX", nOX, szTemp );
  593.            StructGet ( rect, "WINRECTSTRUCT", "origY", nOY, szTemp );
  594.            StructGet ( rect, "WINRECTSTRUCT", "relX" , nSX, szTemp );
  595.            StructGet ( rect, "WINRECTSTRUCT", "relY" , nSY, szTemp );
  596.            nRet = 0;
  597.  
  598.         endif;
  599.  
  600.         return nRet;
  601. end;
  602.  
  603.  
  604. //-----------------------------------------------------------------------------
  605. // PARAMETERS:
  606. //      (INPUT)
  607. //      hWnd specifies the window.
  608. //      (OUTPUT)
  609. //      nOX receives 0.
  610. //      nOY receives 0.
  611. //      nSX receives the width of the window.
  612. //      nSY receives the height of the window.
  613. // PURPOSE
  614. //       This function retrieves the client coordinates of a window's client
  615. //       area.
  616. //
  617. //-----------------------------------------------------------------------------
  618. function _WinSubGetClientRect ( hWnd, nOX, nOY, nSX, nSY )
  619.  
  620. NUMBER          nRet;
  621. POINTER         pRect;
  622. WINRECTSTRUCT   rect;
  623. STRING          szTemp [MAX_WINSUB_TMPSTRING_LENGTH];
  624.  
  625. begin
  626.  
  627.         // Check window handle
  628.         if ( _WinSubIsWindow ( hWnd ) <= 0 ) then
  629.            return -1;
  630.         endif;
  631.  
  632.         // Retrieve the address of the structure
  633.         pRect = AddressStruct ( rect );
  634.  
  635.         // Retrieve window rect
  636.         nRet = GetClientRect ( hWnd, pRect );
  637.         if ( nRet = -1 ) then
  638.  
  639.            // Can not locate the function?
  640.            _WinSubErrDLLFunc ( "GetClientRect" );
  641.            nRet = -1;
  642.  
  643.         else
  644.  
  645.            // Separate each field of the rect structure
  646.            StructGet ( rect, "WINRECTSTRUCT", "origX", nOX, szTemp );
  647.            StructGet ( rect, "WINRECTSTRUCT", "origY", nOY, szTemp );
  648.            StructGet ( rect, "WINRECTSTRUCT", "relX" , nSX, szTemp );
  649.            StructGet ( rect, "WINRECTSTRUCT", "relY" , nSY, szTemp );
  650.            nRet = 0;
  651.  
  652.         endif;
  653.  
  654.         return nRet;
  655. end;
  656.  
  657.  
  658. //-----------------------------------------------------------------------------
  659. // PARAMETERS:
  660. //      hWnd specifies the window.
  661. //      nNX specifies X-coord. of the new upper-left corner.
  662. //      nNY specifies Y-coord. of the new upper-left corner.
  663. //      nSX specifies the width of the window.
  664. //      nSY specifies the height of the window.
  665. //      sFlags supports all SWP_* available in SetWindowPos API.
  666. // PURPOSE
  667. //     This function changes the size, position, and Z-order of child,
  668. //     pop-up, and top-level windows.
  669. //
  670. //-----------------------------------------------------------------------------
  671. function        _WinSubSetWindowPos ( hWnd, nNX, nNY, nSX, nSY, sFlags )
  672.  
  673. NUMBER          nRet;
  674.  
  675. begin
  676.  
  677.         // Check window handle
  678.         if ( _WinSubIsWindow ( hWnd ) <= 0 ) then
  679.            return -1;
  680.         endif;
  681.  
  682.         // Move window
  683.         nRet = SetWindowPos ( hWnd, 0, nNX, nNY, nSX, nSY, sFlags );
  684.         if ( nRet = -1 ) then
  685.  
  686.            _WinSubErrDLLFunc ( "SetWindowPos" );
  687.            nRet = -1;
  688.  
  689.         else
  690.  
  691.            nRet = 0;
  692.  
  693.         endif;
  694.  
  695.         return nRet;
  696. end;
  697.  
  698.  
  699. //-----------------------------------------------------------------------------
  700. // PARAMETERS:
  701. //      hWnd specifies the window.
  702. //      nNX specifies X-coord. of the new upper-left corner.
  703. //      nNY specifies Y-coord. of the new upper-left corner.
  704. //      nSX specifies the width of the window.
  705. //      nSY specifies the height of the window.
  706. //      sFlags specifies whether to redraw the window.
  707. // PURPOSE
  708. //      This function changes the position and dimensions of a window.
  709. //
  710. //-----------------------------------------------------------------------------
  711. function        _WinSubMoveWindow ( hWnd, nNX, nNY, nSX, nSY, sFlags )
  712.  
  713. NUMBER          nRet;
  714.  
  715. begin
  716.  
  717. #ifdef CHECKWINDOW=1
  718.         if ( _WinSubIsWindow ( hWnd ) <= 0 ) then
  719.            return -1;
  720.         endif;
  721. #endif
  722.  
  723.         // Move window
  724.         nRet = MoveWindow ( hWnd, nNX, nNY, nSX, nSY, sFlags );
  725.         if ( nRet = -1 ) then
  726.  
  727.            _WinSubErrDLLFunc ( "MoveWindow" );
  728.            nRet = -1;
  729.  
  730.         else
  731.  
  732.            nRet = 0;
  733.  
  734.         endif;
  735.  
  736.         return nRet;
  737. end;
  738.  
  739.  
  740. //-----------------------------------------------------------------------------
  741. // PARAMETERS:
  742. //      hWnd specifies the window.
  743. //      nCmd specifies the type of message posted.
  744. //      sParam1 specifies additional message information.
  745. //      lParam2 specifies additional message information.
  746. // PURPOSE
  747. //      This function posts a message in a window's message queue and
  748. //      then returns without waiting for the corresponding window to process
  749. //      the message.
  750. //
  751. //-----------------------------------------------------------------------------
  752. function   _WinSubPostMessage ( hWnd, nCmd, sParam1, lParam2 )
  753.  
  754. NUMBER          nRet;
  755.  
  756. begin
  757.  
  758.         // Move window
  759.         nRet = PostMessage ( hWnd, nCmd, sParam1, lParam2 );
  760.         if ( nRet = -1 ) then
  761.  
  762.            _WinSubErrDLLFunc ( "PostMessage" );
  763.            nRet = -1;
  764.  
  765.         else
  766.  
  767.            nRet = 0;
  768.  
  769.         endif;
  770.  
  771.         return nRet;
  772. end;
  773.  
  774. //-----------------------------------------------------------------------------
  775. // PARAMETERS:
  776. //      szDLLFuncName specifies the DLL function name which returns -1.
  777. // PURPOSE
  778. //
  779. //-----------------------------------------------------------------------------
  780. function        _WinSubErrDLLFunc ( szDLLFuncName )
  781.  
  782. STRING          szMsg [MAX_WINSUB_MSGSTRING_LENGTH];
  783.  
  784. begin
  785.  
  786.         szMsg = "InstallShield can not call DLL function: " + szDLLFuncName;
  787.         MessageBox ( szMsg, SEVERE );
  788.  
  789. end;
  790.  
  791.  
  792.  
  793.